package user

import "golang.org/x/crypto/bcrypt"

// EncryptPWD 密码加密
func EncryptPWD(pwd string) ([]byte, error) {
	return bcrypt.GenerateFromPassword([]byte(pwd), bcrypt.DefaultCost)
}

// CheckPWD 验证密码
func CheckPWD(hashedPwd string, pwd []byte) bool {
	err := bcrypt.CompareHashAndPassword([]byte(hashedPwd), pwd)
	if err != nil {
		return false
	}
	return true
}
